<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <title>Document</title>
</head>
<body>
    <script>
        (function(){
            var aaa = "123";

            /**
             * 所谓词法作用域，是我在代码中写了引用这个变量，我这个变量的作用域才用在这个范围内有效
             * @constructor
             */
            var Test = function(){
                debugger;
                console.log(aaa); //如果没有这行 debugger时候 aaa是undefined
                var self = this;
                self.test2 = function(){
                    debugger;
                };
            };

            Test.prototype.test1 = function(){
                debugger;
            };

            var t1 = new Test();
            t1.test1();
            t1.test2();
        })();
    </script>
</body>
</html>